$(function () {
    $(".cooperation_button").click(function () {

        $("#BgDiv").css({display: "block", height: $(document).height(), width: $(document).width(), position: "absolute", top: "0", background: "#ecebeb", opacity: "0.6"});
        $(".modal").show();
        document.documentElement.scrollTop = 60;
    });
    $(".close").click(function () {
        $("#BgDiv").css("display", "none");
        $(".modal").css("display", "none");
    });
    $(".success_close").click(function () {
        $("#BgDiv").css("display", "none");
        $(".modal_success").css("display", "none");
    });
    $("#intention_submit").click(function () {

        var mobile = $("#mobile").val();

        var imageCaptcha = $("#imageCaptcha").val();
        var intention = $("#intention").val();
        if (mobile === "") {
            $("#msg_pwd").html("警告:填写手机号码不能为空！");
            return false;
        }
        else {
            if (!isMoible(mobile)) {
                $("#msg_pwd").html("警告:填写手机号码格式不正确！");
                return false;
            }
            else {
                $("#msg_pwd").html("");
            }
        }
        if (imageCaptcha === "") {
            $("#msg_pwd").html("警告:图片验证码不能为空！");
            return false;
        }
        $.ajax({
            type: "post",
            url: "/addCooperation.do",
            timeout: 1000,
            data: {mobile: mobile, imageCaptcha: imageCaptcha, intention: $.trim(intention)},
            dataType: "text",
            cache: false,
            success: function (data) {
                if (data.success) {
                    alert("保存成功!");
                    ("#BgDiv").css("display", "block");
                    $(".modal").css("display", "none");
                    $(".modal_success").css("display", "block");
                } else {
                    alert(data.message);
                    ("#BgDiv").css("display", "none");
                    $(".modal").css("display", "none");
                }
            }
        });
    });
});
function reImg() {
    var img = document.getElementById("Img");
    img.src = "captcha.do?" + Math.random();
}
function isMoible(mobile) {
    if (!(/^1[3|4|5|7|8][0-9]\d{8}$/.test(mobile))) {
        return false;
    }
    return true;
}

